<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
   <head>
<%=javascript_include_tag 'prototype'%>

   </head>
	<body>
		<h2>choose one or more images </h2>
			<br/>		
		<form name="postform" id="postform" action = "http://www.click2edit.com/articles1/new" method="post">
      <%=hidden_field_tag 'selectiontext',params[:selection]%>
      <%=hidden_field_tag 'surl',params[:url]%>
			<% if( @images.length>0) %>
 
			<% imgcut=0 %>
      <%@images.each do  |imageurl|%>

      <%= check_box_tag "cbx[]",imageurl,false %>     <img id='img_index' src='<%=h imageurl%>'></img><br/>
      <% imgcut=imgcut+1 %>
      <%end%>
			
			
			<% end %>
			<%=submit_tag 'post new article',:onclick =>"return mytest()"%>
		</form>
	</body>
</html>
<script language="javascript" type = "text/javascript">
 function mytest()
 {
	var cbxList = document.getElementsByName('cbx[]');


  var checkcount = 0;
	for (var i = 0; i < cbxList.length; i++)
	{
	  if (cbxList[i].checked)   
	  checkcount = checkcount+1;
	}
	
	if (checkcount>0)
	{
	 return true;
	}
	else
	{
	  alert ('please select at least one picture'); 
	  return false;
	}

   
 }

 </script>
